from Crypto import Random
from Crypto.Cipher import AES
import base64

BLOCK_SIZE=16
IV = Random.new().read(BLOCK_SIZE)

def encrypt(message, iv, passphrase):
    # passphrase MUST be 16, 24 or 32 bytes long, how can I do that ?
    # print(len(IV))
    print(iv,11)
    aes = AES.new(passphrase, AES.MODE_CFB, iv)
    return iv+aes.encrypt(message)

def decrypt(encrypted, passphrase):
    # print(encrypted)
    iv = encrypted[:16]
    print(iv,11)
    aes = AES.new(passphrase, AES.MODE_CFB, iv)
    return aes.decrypt(encrypted[16:])


if __name__ == "__main__":
    passphrase = "keyskeyskeyskeys"
    e = encrypt("0011231m123k1m123k123123", IV, passphrase)
    d = decrypt(e, passphrase)
    print(d)